#include "Stack.h"
#include <iostream>
using namespace std;

Stack::Stack():LinkedList()
{
}

Stack::~Stack()
{
	LinkedList::clear();
}

void Stack::push(int value)
{
	LinkedList::add(value); //appends the given value to the beginning of the list
}
int Stack::pop()
{
	int val=get(size()-1); //get the last value of the list (the one "on top")
	LinkedList::remove(size()-1); //remove what's at the end/"top"
	return val;
}

void Stack::print()
{
	int a;
	if(LinkedList::isEmpty())
	{
		cout << "<Stack instance at " << this << ">" << endl << "no items"<<endl;
	}
	else
	{
		cout << "<Stack instance at " << this << ">" << endl << "TOP" << endl;
		for(a=Size-1;a>=0;a--) //go from "top"(end) to "bottom" (beginning)
		{
			cout << get(a) << ";" << endl;
		}
	}
	cout << "BOTTOM" << endl << "</Stack>" << endl;
}
